package org.melanesia.converters.java;

import org.melanesia.converters.JavaToJavaConverter;

/**
 * Converts string representation of an Enum into an instance of this Enum
 * @author mkielar
 *
 * @param <T> Enum class name
 */
public class StringToEnumConverter<T extends Enum<T>> implements JavaToJavaConverter {
	
	private Class<T> enumClass;
	
	public StringToEnumConverter(Class<T> enumClass) {
		this.enumClass = enumClass;
	}
	
	@Override
	public Object convert(Object value) {
		return Enum.valueOf(enumClass, (String)value);
	}
};
